package org.example.zrccddllljh.Controlelr;

import org.example.zrccddllljh.Pojo.Doctor;
import org.example.zrccddllljh.Pojo.Result;
import org.example.zrccddllljh.Service.DockerlListServie;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/doctorlist")
public class DoctorListController {
    @Autowired
    private DockerlListServie dockerlListServie;
    @GetMapping("/all")
    public Result<List<Doctor>> list(){

        List<Doctor> dl =dockerlListServie.list();
        return Result.success(dl);
    }
    @PutMapping
    public  Result updata(@RequestBody Doctor doctor){

        dockerlListServie.upadte(doctor);
        return Result.success();
    }
    @PostMapping("/add")
    public  Result add( @RequestBody Doctor doctor){
        dockerlListServie.add(doctor);
        return Result.success();

    }
    @DeleteMapping
    public Result delete(Integer id){
        dockerlListServie.deleteById(id);
        return Result.success();
    }

    @GetMapping
    public Result<List<Doctor>> list(
            @RequestParam(required = false) Integer pageNow,
            @RequestParam(required = false) Integer pageSize

    ) {

        List<Doctor> pb= dockerlListServie.list(pageNow,pageSize);
        System.out.println(pb);
        return Result.success(pb);
    }

    @GetMapping("aaa")
    public Result<List<Doctor>> lists(
            @RequestParam(required = false) Integer pageNow,
            @RequestParam(required = false) Integer pageSize,
            String  department,String state

    ) {

        System.out.println( "department="+ department);
        System.out.println("state="+ state);
        List<Doctor> pb= dockerlListServie.list(pageNow,pageSize,department,state);

        return Result.success(pb);
    }

}
